package cn.iocoder.yudao.module.handguard.dal.mysql.orderprocessrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.orderprocessrecord.OrderProcessRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.app.orderprocessrecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 订单审核流程记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OrderProcessRecordMapper extends BaseMapperX<OrderProcessRecordDO> {

    default PageResult<OrderProcessRecordDO> selectPage(OrderProcessRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderProcessRecordDO>()
                .eqIfPresent(OrderProcessRecordDO::getOrderApplicationId, reqVO.getOrderApplicationId())
                .eqIfPresent(OrderProcessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OrderProcessRecordDO::getFlowN, reqVO.getFlowN())
                .eqIfPresent(OrderProcessRecordDO::getCauseOfFailure, reqVO.getCauseOfFailure())
                .betweenIfPresent(OrderProcessRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OrderProcessRecordDO::getIsFail, reqVO.getIsFail())
                .orderByDesc(OrderProcessRecordDO::getId));
    }

    default List<OrderProcessRecordDO> selectList(OrderProcessRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrderProcessRecordDO>()
                .eqIfPresent(OrderProcessRecordDO::getOrderApplicationId, reqVO.getOrderApplicationId())
                .eqIfPresent(OrderProcessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OrderProcessRecordDO::getFlowN, reqVO.getFlowN())
                .eqIfPresent(OrderProcessRecordDO::getCauseOfFailure, reqVO.getCauseOfFailure())
                .betweenIfPresent(OrderProcessRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OrderProcessRecordDO::getIsFail, reqVO.getIsFail())
                .orderByDesc(OrderProcessRecordDO::getId));
    }

    int deleteRecordById(@Param("orderId") Long orderId);
}
